package com.itheima.map;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class mapDemo02 {
    public static void main(String[] args) {
        HashMap<Student,String> hm=new HashMap<>();
        Student stu1=new Student("zhangsan",18);
        Student stu2=new Student("lisi",22);
        Student stu3=new Student("wangwu",19);
        hm.put(stu1,"男");
        hm.put(stu2,"女");
        hm.put(stu3,"女");
        hm.forEach((Student key,String value)->{
            System.out.println(key+"--------"+value);
        });
        System.out.println("======================");
        Set<Map.Entry<Student, String>> entries = hm.entrySet();
        for (Map.Entry<Student, String> entry : entries) {
            Student key = entry.getKey();
            String value = entry.getValue();
            System.out.println(key+"--------"+value);
        }
        System.out.println("======================");
        Set<Student> keySet = hm.keySet();
        for (Student key : keySet) {
            String value = hm.get(key);
            System.out.println(key+"--------"+value);
        }
    }
}
